package com.dc.server.mq;


import com.dc.server.constant.QueueDict;
import com.dc.server.entity.UserEntity;
import com.dc.server.service.UserService;
import com.dc.server.util.MqSender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.handler.annotation.Payload;

/**
 * 审核 step0公共规则
 * 需要的数据： 凭安、自有、运营商、白骑士
 */
@Slf4j
@Configuration
@RabbitListener(queues = QueueDict.QueueName_AutoAudit_Step0_Ready, containerFactory = "rabbitListenerContainerFactory")
public class AuditListenerStep0 {

    private static final String STEONAME = "审核步骤[step0公共规则]";

    @Autowired
    private MqSender mqSender;
    @Autowired
    private UserService userService;

    //下一步骤:Step1(新客)/Step5(老客)审核 数据准备
    private String nextQueue1Name = QueueDict.QueueName_AutoAudit_Step1_Ready;

    @Bean("step0Queue")
    public Queue step0Queue() {
        return new Queue(QueueDict.QueueName_AutoAudit_Step0_Audit);
    }

    @RabbitHandler
    public void process(@Payload String auditBean) {
        UserEntity userEntity = userService.selectById(1);
        log.info("进入消息队列", auditBean);
    }

}
